﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

using RexToy.UI.WinForm.Pmlx;
using RexToy.UI.WinForm.ViewModel;

namespace RexToy.UI.WinForm.Controls
{
    public class StatusLabel : ToolStripStatusLabel, IDataExchange
    {
        public StatusLabel()
        {
            _exchange = true;
        }

        public void UpdateModel(ViewModelBase model)
        {
            //Note:Readonly control, do nothing.
        }

        public void UpdateView(ViewModelBase model)
        {
            IReflector r = Reflector.Bind(model);
            object val = r.GetPropertyValue(this.BindPropertyName);
            if (val != null)
                this.Text = val.ToString();
            else
                this.Text = string.Empty;
        }

        private string _bindPropertyName;
        public string BindPropertyName
        {
            get { return this.GetBindProperty(_bindPropertyName); }
            set { _bindPropertyName = value; }
        }

        public UpdateModelTrigger UpdateModelTrigger { get; set; }

        private bool _exchange;
        public bool Exchange
        {
            get { return _exchange; }
            set { _exchange = value; }
        }
    }
}
